
# 以百度翻译为例

import requests
import json

url = 'https://fanyi.baidu.com/sug'
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
}
data = {
    'kw':'西瓜'
}
response = requests.post(url=url,data=data,headers=headers)
html = response.text
html = json.loads(html)
# json.loads(html,encoding='utf-8')  不需要 encoding
print(html)


